﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ElingOA6_Admin_DSJCJ.Model
{
    [Serializable]
    public partial class Calendar
    {
        public Calendar()
        {
            FIsWake = "N";
            FPri = "2";
            FIsAllDayEvent = "N";
            FWakeMinutes = -1;
        }
        #region Model
        /// <summary>
        /// 个人事务编号
        /// </summary>
        public decimal FCalendarID
        {
            set;
            get;
        }
        /// <summary>
        /// 标题
        /// </summary>
        public string FTitle
        {
            set;
            get;
        }
        /// <summary>
        /// 内容
        /// </summary>
        public string FContents
        {
            set;
            get;
        }
        /// <summary>
        /// 是否提醒

        /// </summary>
        public string FIsWake
        {
            set;
            get;
        }
        /// <summary>
        /// 开始时间
        /// </summary>
        public DateTime FBeginDate
        {
            set;
            get;
        }
        /// <summary>
        /// 结束时间
        /// </summary>
        public DateTime FEndDate
        {
            set;
            get;
        }
        /// <summary>
        /// 优先级
        ///1 高
        ///2 普通
        ///3 低
        /// </summary>
        public string FPri
        {
            set;
            get;
        }
        /// <summary>
        /// 最近提醒时间
        /// </summary>
        public DateTime? FLastWakeTime
        {
            set;
            get;
        }
        /// <summary>
        /// 下次提醒时间
        /// </summary>
        public DateTime? FNextWakeTime
        {
            set;
            get;
        }
        /// <summary>
        /// 是否全天事件

        /// </summary>
        public string FIsAllDayEvent
        {
            set;
            get;
        }
        /// <summary>
        /// 提前提醒时间，填写提前提醒的分钟数
        /// </summary>
        public int? FWakeMinutes
        {
            set;
            get;
        }
        private string _WakeStr;

        public string WakeStr
        {
            set { _WakeStr = value; }
            get
            {
                if (!string.IsNullOrEmpty(_WakeStr))
                {
                    return _WakeStr;

                }
                else
                {

                    if (!string.IsNullOrEmpty(FWakeMinutes.ToString()))
                    {
                        TimeSpan expired = new TimeSpan(0, int.Parse(FWakeMinutes.ToString()), 0);
                        string strout = "";
                        if (expired.TotalSeconds > 0)
                        {

                            if (expired.TotalDays >= 1)
                            {
                                strout += Math.Round(expired.TotalDays, 0) + "d";
                            }
                            else
                            {
                                if (expired.TotalHours >= 1)
                                {
                                    strout += Math.Round(expired.TotalHours, 0) + "h";
                                }
                                else
                                {
                                    if (expired.TotalMinutes >= 1)
                                    {
                                        strout += Math.Round(expired.TotalMinutes, 0) + "m";
                                    }
                                    else
                                    {
                                        strout += Math.Round(expired.TotalSeconds, 0) + "s";
                                    }
                                }
                            }
                        }
                        else
                        {
                            return "none";
                        }
                        return strout;
                    }
                    else
                    {
                        return "none";
                    }



                }
            }
        }
        /// <summary>
        /// 公司编码
        /// </summary>
        public string FEntityNo
        {
            set;
            get;
        }
        /// <summary>
        /// 员工编号
        /// </summary>
        public string FEmplNo
        {
            set;
            get;
        }
        /// <summary>
        /// 录入时间
        /// </summary>
        public DateTime FInputTime
        {
            set;
            get;
        }
        public int IsAllDay
        {
            get
            {
                return FIsAllDayEvent == "Y" ? 1 : 0;
            }
        }
        //新增提醒时间
        private string _ReminderInfo;
        public string ReminderInfo
        {
            set
            {
                _ReminderInfo = value;
            }
            get
            {
                if (!string.IsNullOrEmpty(_ReminderInfo))
                {
                    return _ReminderInfo;
                }
                else
                {
                    if (!string.IsNullOrEmpty(FNextWakeTime.ToString()))
                    {
                        return "<Reminders><Reminder AlertTime=\"" + DateTime.Parse(FNextWakeTime.ToString()).ToString("MM/dd/yyyy HH:mm:ss") + "\"/></Reminders>";
                    }
                    return "";
                }
            }
        }
        //过期时间字符串

        public string ExpireStr
        {
            get
            {
                if (FNextWakeTime != null)
                {
                    string strout = "";
                    TimeSpan expired = DateTime.Now - (DateTime)FBeginDate;
                    if (expired.TotalSeconds > 0)
                    {
                        strout = "过期";
                        if (expired.TotalDays >= 1)
                        {
                            strout += Math.Round(expired.TotalDays, 0) + "天";
                        }
                        else
                        {
                            if (expired.TotalHours >= 1)
                            {
                                strout += Math.Round(expired.TotalHours, 0) + "小时";
                            }
                            else
                            {
                                if (expired.TotalMinutes >= 1)
                                {
                                    strout += Math.Round(expired.TotalMinutes, 0) + "分钟";
                                }
                                else
                                {
                                    strout += Math.Round(expired.TotalSeconds, 0) + "秒";
                                }
                            }
                        }
                    }
                    else
                    {
                        if (expired.TotalDays <= -1)
                        {
                            strout += -Math.Round(expired.TotalDays, 0) + "天";
                        }
                        else
                        {
                            if (expired.TotalHours <= -1)
                            {
                                strout += -Math.Round(expired.TotalHours, 0) + "小时";
                            }
                            else
                            {
                                if (expired.TotalMinutes <= -1)
                                {
                                    strout += -Math.Round(expired.TotalMinutes, 0) + "分钟";
                                }
                                else
                                {
                                    strout += -Math.Round(expired.TotalSeconds, 0) + "秒";
                                }
                            }
                        }
                    }
                    return strout;
                }
                else
                {

                    return "";
                }



            }
        }
        #endregion Model

    }
}

